package cn.java.exercises;

public class YangHui
{
    public static void main(String[] args)
    {
        int arr[][]=new int [10][10];

        for (int i = 0; i < arr.length; i++)
        {
            for (int j = 0; j < arr.length  - i; j++)
            {
                System.out.print("  "); //金字塔状三角形，前导空格
            }

            arr[i][0]=1;
            System.out.print(String.format("%3d ",arr[i][0]));
            for (int j = 1; j <=i; j++)
            {
                if(j==i) arr[i][j]=1;
                else
                {
                    arr[i][j]=arr[i-1][j-1]+arr[i-1][j];
                }
                System.out.print(String.format("%3d ",arr[i][j]));
            }
            System.out.println("");
        }
    }
}
